import request from '@/utils/request'

// 查询采购入库单列表
export function listReceipt(query) {
  return request({
    url: '/purchase/receipt/list',
    method: 'get',
    params: query
  })
}

// 查询采购入库单详细
export function getReceipt(receiptId) {
  return request({
    url: '/purchase/receipt/' + receiptId,
    method: 'get'
  })
}

// 新增采购入库单
export function addReceipt(data) {
  return request({
    url: '/purchase/receipt',
    method: 'post',
    data: data
  })
}

// 修改采购入库单
export function updateReceipt(data) {
  return request({
    url: '/purchase/receipt',
    method: 'put',
    data: data
  })
}

// 删除采购入库单
export function delReceipt(receiptId) {
  return request({
    url: '/purchase/receipt/' + receiptId,
    method: 'delete'
  })
}

// 校验入库单编号是否唯一
export function checkReceiptCodeUnique(receiptCode, receiptId) {
  return request({
    url: '/purchase/receipt/checkReceiptCodeUnique',
    method: 'get',
    params: {
      receiptCode: receiptCode,
      receiptId: receiptId
    }
  })
}

// 根据供应商ID查询入库单列表
export function listReceiptBySupplierId(supplierId) {
  return request({
    url: '/purchase/receipt/listBySupplierId/' + supplierId,
    method: 'get'
  })
}

// 审核采购入库单
export function auditReceipt(receiptId, status) {
  return request({
    url: '/purchase/receipt/audit/' + receiptId + '/' + status,
    method: 'put'
  })
}

// 执行采购入库单
export function executeReceipt(receiptId) {
  return request({
    url: '/purchase/receipt/execute/' + receiptId,
    method: 'put'
  })
}